Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class System.​Collections.​Generic.​Queue<​T>
Assembly: System.Collections
Inheritance: object → Queue
Implemented Interfaces
- IReadOnlyCollection`1 (Inherits: IEnumerable<​T>IEnumerable)
- ICollection (Inherits: IEnumerable)
Represents a first-in, first-out collection of objects.
Properties
public
int
Count
Gets the number of elements contained in the <see cref="T:System.Collections.Generic.Queue`1" /> .
public
int
Capacity
Gets the total numbers of elements the internal data structure can hold without resizing.
Methods
public
void
Clear​()
Removes all objects from the <see cref="T:System.Collections.Generic.Queue`1" /> .
public
bool
Contains​(T item)
Determines whether an element is in the <see cref="T:System.Collections.Generic.Queue`1" /> .
Returns <see langword="true" /> if <paramref name="item" /> is found in the <see cref="T:System.Collections.Generic.Queue`1" /> ; otherwise, <see langword="false" /> .
item
The object to locate in the <see cref="T:System.Collections.Generic.Queue`1" /> . The value can be <see langword="null" /> for reference types.
public
void
CopyTo​(T[] array,
int arrayIndex)
Copies the <see cref="T:System.Collections.Generic.Queue`1" /> elements to an existing one-dimensional <see cref="T:System.Array" /> , starting at the specified array index.
array
The one-dimensional <see cref="T:System.Array" /> that is the destination of the elements copied from <see cref="T:System.Collections.Generic.Queue`1" /> . The <see cref="T:System.Array" /> must have zero-based indexing.
arrayIndex
The zero-based index in <paramref name="array" /> at which copying begins.
public
T
Dequeue​()
Removes and returns the object at the beginning of the <see cref="T:System.Collections.Generic.Queue`1" /> .
Returns The object that is removed from the beginning of the <see cref="T:System.Collections.Generic.Queue`1" /> .
public
void
Enqueue​(T item)
Adds an object to the end of the <see cref="T:System.Collections.Generic.Queue`1" /> .
item
The object to add to the <see cref="T:System.Collections.Generic.Queue`1" /> . The value can be <see langword="null" /> for reference types.
public
Enumerator<​T>
GetEnumerator​()
Returns an enumerator that iterates through the <see cref="T:System.Collections.Generic.Queue`1" /> .
Returns An <see cref="T:System.Collections.Generic.Queue`1.Enumerator" /> for the <see cref="T:System.Collections.Generic.Queue`1" /> .
public
T
Peek​()
Returns the object at the beginning of the <see cref="T:System.Collections.Generic.Queue`1" /> without removing it.
Returns The object at the beginning of the <see cref="T:System.Collections.Generic.Queue`1" /> .
public
T[]
ToArray​()
Copies the <see cref="T:System.Collections.Generic.Queue`1" /> elements to a new array.
Returns A new array containing elements copied from the <see cref="T:System.Collections.Generic.Queue`1" /> .
public
void
TrimExcess​()
Sets the capacity to the actual number of elements in the <see cref="T:System.Collections.Generic.Queue`1" /> , if that number is less than 90 percent of current capacity.
public
void
TrimExcess​(int capacity)
Sets the capacity of a <see cref="T:System.Collections.Generic.Queue`1" /> object to the specified number of entries.
capacity
The new capacity.
public
int
EnsureCapacity​(int capacity)
Ensures that the capacity of this queue is at least the specified <paramref name="capacity" /> . If the current capacity is less than <paramref name="capacity" /> , it is increased to at least the specified <paramref name="capacity" /> .
Returns The new capacity of this queue.
capacity
The minimum capacity to ensure.
public
bool
Equals​(object obj)
Inherited from object
protected
void
Finalize​()
Inherited from object
public
int
GetHashCode​()
Inherited from object
protected
object
MemberwiseClone​()
Inherited from object
public
string
ToString​()
Inherited from object